package com.taxi.driver.module.main.mine.statistical;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.qianxx.utils.TypeUtils;
import com.taxi.driver.R;
import com.taxi.driver.common.Application;
import com.taxi.driver.common.BaseActivity;
import com.taxi.driver.module.main.mine.statistical.dagger.AssessmentStatisticalModule;
import com.taxi.driver.module.main.mine.statistical.dagger.DaggerAssessmentStatisticalComponent;
import com.taxi.driver.module.vo.AssessmentStatisticalVO;
import com.taxi.driver.widget.TimeTable;
import com.taxi.driver.widget.dialog.ConfirmDialog;
import com.taxi.driver.widget.dialog.ContentDialog;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 考核统计
 */
public class AssessmentStatisticalActivity extends BaseActivity implements
        AssessmentStatisticalContract.View, TimeTable.DateListener {
    @BindView(R.id.time_table)
    TimeTable time_table;

    @BindView(R.id.tv_order_count)
    TextView tv_order_count;
    @BindView(R.id.tv_complete_order_count)
    TextView tv_complete_order_count;
    @BindView(R.id.tv_order_probability)
    TextView tv_order_probability;
    @BindView(R.id.tv_order_recode)
    TextView tv_order_recode;
    @BindView(R.id.tv_income_recode)
    TextView tv_income_recode;
    @BindView(R.id.tv_avg_score)
    TextView tv_avg_score;
    @BindView(R.id.tv_complaints_count)
    TextView tv_complaints_count;
//    @BindView(R.id.tv_online_time)
//    TextView tv_online_time;
//    @BindView(R.id.tv_service_time)
//    TextView tv_service_time;
//    @BindView(R.id.tv_online_mileage)
//    TextView tv_online_mileage;

    @Inject
    AssessmentStatisticalPresenter mPresenter;
    private ContentDialog contentDialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_assessment_statistical);
        ButterKnife.bind(this);

        DaggerAssessmentStatisticalComponent.builder()
                .appComponent(Application.getAppComponent())
                .assessmentStatisticalModule(new AssessmentStatisticalModule(this))
                .build().inject(this);

        time_table.setDateListener(this);
        mPresenter.reqAssessmentStatistical(time_table.getStartDate(), time_table.getEndDate());

    }

    @Override
    public boolean isActive() {
        return false;
    }

    @Override
    public void showAssessmentStatistical(AssessmentStatisticalVO vo) {
        tv_order_count.setText(getString(R.string.order_unit, vo.order_count + ""));
        tv_complete_order_count.setText(getString(R.string.order_unit, vo.complete_order_count + ""));
        tv_order_probability.setText(vo.order_probability);
        tv_order_recode.setText(getString(R.string.yuan, vo.order_recode + ""));
        tv_income_recode.setText(getString(R.string.yuan, vo.income_recode + ""));
        tv_avg_score.setText(TypeUtils.getValue2(vo.average_score));
        tv_complaints_count.setText(getString(R.string.count, vo.complaints_count + ""));
//        tv_online_time.setText(getString(R.string.hour,TimeUtils.getHour(vo.online_time)+"")
//                +getString(R.string.minute,TimeUtils.getMinute(vo.online_time)+""));
//        tv_service_time.setText(getString(R.string.hour,TimeUtils.getHour(vo.service_time)+"")
//                +getString(R.string.minute,TimeUtils.getMinute(vo.service_time)+""));
//        tv_online_mileage.setText(getString(R.string.km, TextUtils.isEmpty(vo.online_mileage)?"0":vo.online_mileage));
    }

    @Override
    public void onDate(String startDate, String endDate) {
        mPresenter.reqAssessmentStatistical(startDate, endDate);
    }

    @OnClick({R.id.img_head_right})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_head_right:
                showExplainDialog();
                break;

        }
    }

    /**
     * 显示说明框
     */
    private void showExplainDialog() {
        contentDialog = new ContentDialog(this);
        contentDialog.setTitle(getString(R.string.explain_asses_title))
                .setContent(getString(R.string.explain_asses_content))
                .setAffirmContentColor(R.color.orange_f99358);
        contentDialog.setOnOneClickListener(new ContentDialog.OnOneClickListener() {
            @Override
            public void onAffirm() {

            }
        }).show();

    }
}
